<div class="topbar">
    <div class="container">
        <div class="col-md-12">
            <div class="pull-left">
                <?php if (!Yii::app()->user->id): ?>
                    <span class="welcome">您好，欢迎光临1折网</span>
                    <a class="login" href="<?php echo $this->createUrl('/user/login/login'); ?>" rel="nofollow">登录</a> | 
                    <a class="register" href="<?php echo $this->createUrl('/user/user/register'); ?>" rel="nofollow">注册</a>
                    <a class="register" href="<?php echo $this->createUrl('/user/oauth/qqreg'); ?>" rel="nofollow">
                    	<img src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/images/loginbtn_qq_16x16.png" style="vertical-align:middle" />
                    </a>
                    <a class="register" href="<?php echo $this->createUrl('/user/oauth/sinareg'); ?>" rel="nofollow">
                    	<img src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/images/loginbtn_sina_16x16.png" style="vertical-align:middle" />
                    </a>
                <?php else: ?>
                    <a class="login" href="<?php echo $this->createUrl('/user/info/index'); ?>" rel="nofollow">您好<?php echo Yii::app()->user->name; ?>，进入会员中心</a> | 
                    <a class="login" href="<?php echo $this->createUrl('/user/user/logout'); ?>" rel="nofollow">退出</a>
                    
                <?php endif ?>
            </div>
            <?php 
            if (Yii::app()->user->id): 
            	$messcount = MessageModel::model()->isNews(Yii::app()->user->id);
            ?>
            <div class="pull-left message_top" <?php if($messcount > 0) echo 'id="message_top"';?> >
            	<div class="reg-spt <?php if($messcount == 0) echo 'msg_icon_tray'; else echo "msg_icon";?>"></div>
            	<a class="msg_a" href="/user/message/list.html" target="_blank">消息</a>
            	<div class="msg_num"><?php echo $messcount ?></div>
            	<i class="arrow"></i>
            	
            	<div class="msg_list">
            		<div class="msg_title">未读新消息</div>
            		
            		
            		<!--
            		
            		
            		
            		<div class="msg_content">
            			<div class="content_title">
            				<div class="pull-left left-icon"></div>
            				<div class="pull-left pink_name">标题标题标题</div>
            				<div class="clear"></div>
            			</div>
            			<div class="content_info">
            				<div class="info_desc">初审通过 请邮寄商品</div>
            			</div>
            		</div>
            		
            		<div class="msg_content">
            			<div class="content_title">
            				<div class="pull-left left-icon"></div>
            				<div class="pull-left pink_name">报名宝贝</div>
            				<div class="pull-left black">已经通过审核</div>
            				<div class="clear"></div>
            			</div>
            			<div class="content_info">
            				<img class="pull-left" alt="" src="<?php echo Yii::app()->theme->baseUrl; ?>/assets/images/report_success.png">
            				<div class="pull-left info_desc">
            					<div class="goods_name black">商品名称</div>
            					<div class="goods_time">2014年10月10日 11:11:11</div>
            					<div class="goods_desc">初审通过 请邮寄商品</div>
            				</div>
            				<div class="clear"></div>
            			</div>
            		</div>
            		-->
            		
            		<div class="msg_footer">
            			<a class="all" target="_blank" href="/user/message/list.html">查看全部</a>
            		</div>
            		<div class="clear"></div>
            	</div>
            </div>
            <?php endif ?>
            
            <div class="pull-right">
                <a class="sina" href="http://weibo.com/1zwcom " rel="nofollow" target="_blank"><i class="front-spt"></i>1折网官方微博</a> | 
	            <a class="bangpai" href="http://bbs.1zw.com" target="_blank">1折网论坛</a>
            </div>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
<script type="text/javascript">

$('#message_top,.msg_list').mouseover(function() {
	msg_ajax();
    $('#message_top').addClass('message_top_hover');
    $('.msg_list').show();
});
$('#message_top,.msg_list').mouseout(function() {
    $('#message_top').removeClass('message_top_hover');
    $('.msg_list').hide();
});


var msg = false;
function msg_ajax() {
    if(msg)
        return false;
	$.ajax({
        url: '/user/message/notice.html',
        type: "GET",
        timeout: 5000,
        dataType: "html",
        success: function(data) {
            if (data == '') 
                return false;
			
			$(".msg_list").html("");
            $(".msg_list").prepend('<div class="msg_title">未读新消息</div>'+data+'<div class="msg_footer"><a class="all" target="_blank" href="/user/message/list.html">查看全部</a></div<div class="clear"></div>');
            
            //$("img.lazy").lazyload();
            msg = true;
        }

    });
	return false;
}
</script>

